package com.ruoyi.app.controller;

import com.ruoyi.app.dto.MemberInvoiceDto;
import com.ruoyi.app.service.IInvoiceService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * App端 - 电子发票相关
 */
@CrossOrigin
@RestController
@RequestMapping("/app/invoice")
public class AppInvoiceController extends BaseController {

    @Autowired
    private IInvoiceService invoiceService;

    /**
     * 获取发票授权地址
     * @return
     */
    @GetMapping("/getAuthUrl")
    public AjaxResult getAuthUrl(String orderNo, String uniqueId){
        return success(invoiceService.getAuthUrl(orderNo, uniqueId));
    }

    /**
     * 查询发票授权状态
     * @return
     */
    @GetMapping("/getAuthData")
    public AjaxResult getAuthData(String orderNo){
        return success(invoiceService.getAuthData(orderNo));
    }

    /**
     * 创建发票模板
     * @return
     */
    @PostMapping("/createTemplate")
    public AjaxResult createTemplate(){
        return success(invoiceService.createTemplate());
    }

    /**
     * 获取商户开票基础信息
     * @return
     */
    @GetMapping("/baseInformation")
    public AjaxResult baseInformation(){
        return success(invoiceService.baseInformation());
    }

    /**
     * 申请开票
     * @return
     */
    @PostMapping("/apply")
    public AjaxResult apply(@RequestBody MemberInvoiceDto memberInvoiceDto){
        return success(invoiceService.apply(memberInvoiceDto));
    }

}
